package com.cloudfun.campusshare.common.model.vo;

import com.cloudfun.campusshare.common.constant.DeviceType;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalTime;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2020/5/9 16:43
 * @description :
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "运营平台设备详情")
public class DeviceDetailForOperVO {
    @ApiModelProperty("id")
    private String id;

    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    @ApiModelProperty(value = "归属洗衣点Id")
    private String washPointId;

    @ApiModelProperty(value = "归属洗衣点名称")
    private String washPointName;

    @ApiModelProperty(value = "洗衣点具体地址id")
    private String concretePositionId;

    @ApiModelProperty(value = "栋")
    private String building;

    @ApiModelProperty(value = "层")
    private String floor;

    @ApiModelProperty(value = "室")
    private String room;

    @ApiModelProperty(value = "品牌Id")
    private String brandId;

    @ApiModelProperty(value = "品牌名称")
    private String brandName;

    @ApiModelProperty(value = "设备类型")
    private String productType;


    @ApiModelProperty(value = "sim卡号")
    private String simCard;

    @ApiModelProperty(value = "商家id")
    private String userId;

    @ApiModelProperty(value = "归属运营商名称")
    private String belongOperatorName;

    @ApiModelProperty(value = "设备型号")
    private String deviceType;

    @ApiModelProperty(value = "添加时间")
    private String bindTime;

    @ApiModelProperty(value = "添加人")
    private String creatorName;

    @ApiModelProperty(value = "设备状态")
    private String deviceStatus;

    @ApiModelProperty(value = "设备识别码")
    @JsonProperty("deviceId")
    private String imei;

    @ApiModelProperty(value = "服务时间id")
    private String serviceTimeId;

    @ApiModelProperty(value = "开始服务时间")
    private LocalTime startTime;

    @ApiModelProperty(value = "结束服务时间")
    private LocalTime endTime;

    @ApiModelProperty(value = "设备模式集id")
    private String modeSetId;

    @ApiModelProperty(value = "设备模式集名称")
    private String modeSetName;

    @ApiModelProperty(value = "关联设备imei")
    private String releteImei;

    @ApiModelProperty(value = "洗衣液余量")
    private int laundryDetergent;

    @ApiModelProperty(value = "消毒液余量")
    private int disinfectant;

    @ApiModelProperty(value = "洗衣液默认容量")
    private Integer lDefaultSize;

    @ApiModelProperty(value = "消毒液默认容量")
    private Integer dDefaultSize;

    @ApiModelProperty(value = "洗衣液补货按钮是否能操作")
    private boolean laundryOperation;

    @ApiModelProperty(value = "消毒液补货按钮是否能操作")
    private boolean disinfectantOperation;

    public Integer getlDefaultSize() {
        return lDefaultSize;
    }

    public void setlDefaultSize(Integer lDefaultSize) {
        this.lDefaultSize = lDefaultSize;
    }

    public Integer getdDefaultSize() {
        return dDefaultSize;
    }

    public void setdDefaultSize(Integer dDefaultSize) {
        this.dDefaultSize = dDefaultSize;
    }

    public void checkOperation(int lThreshold, int dThreshold, int replenishStatus){
        if(replenishStatus != 1){
            if(laundryDetergent <= lThreshold){
                this.laundryOperation = true;
            }
            if(disinfectant <= dThreshold && StringUtils.equals(deviceType, DeviceType.PUMP_LA_2.name())){
                this.disinfectantOperation = true;
            }
        }
    }
}
